﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using SMSSnew.DATA;

namespace SMSSnew.UI
{
    public partial class StudentCreateAcc : System.Web.UI.Page
    {
        userAccountDA studentData = new userAccountDA();

        protected void Page_Load(object sender, EventArgs e)
        {

            //DataTable dataTblGrade = new DataTable();
            //DataTable dataTblClass = new DataTable();

            //if (!IsPostBack)
            {


                //dataTblClass = studentData.loadClass_id();
                //dataTblGrade = studentData.loadGrade_id();

                //for (int i = 0; i < dataTblClass.Rows.Count; i++)
                //{
                //    comSecQuestion.Items.Insert(i, dataTblClass.Rows[i][0].ToString());
                //}

                //for (int i = 0; i < dataTblGrade.Rows.Count; i++)
                //{
                //    comSecAnswer.Items.Insert(i, dataTblGrade.Rows[i][0].ToString());
                //}

            }
            
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            if (txtPword.Text == txtRetypePword.Text)
            {
                studentData.createUser(txtUname.Text, txtPword.Text, comSecQ.SelectedValue, txtFname.Text, txtSecAnswer.Text, txtEmail.Text, txtPhone.Text, "STU");
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('User account created successfully. !');", true);
                Response.Redirect("userAccountHome.aspx");
            
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Passwords Entered Incorrectly. Please Try Again !');", true);
                txtRetypePword.Text = "";
                txtPword.Text = "";
            }

        }

        protected void txtFname_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
